<h1></h1>
<!--
Copyright (c) 2019-2026, Hossein Moein
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.
* Neither the name of Hossein Moein and/or the DataFrame nor the
  names of its contributors may be used to endorse or promote products
  derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Hossein Moein BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<!DOCTYPE html>
<html>
<body>

  <table align="center" border="1">

    <tr bgcolor="lightblue">
      <th>Signature</th> <th>Description</th> <th>Parameters</th>
    </tr>
    <tr bgcolor="lightgrey">
      <td bgcolor="maroon"> <font color="white">
        <PRE><B>#include &lt;DataFrame/DataFrameStatsVisitors.h&gt;

template&lt;typename T, typename I = unsigned long,
         std::size_t A = 0&gt;
struct PolyFitVisitor;

// -------------------------------------

template&lt;typename T, typename I = unsigned long,
         std::size_t A = 0&gt;
using pfit_v = PolyFitVisitor&lt;T, I, A&gt;;
        </B></PRE></font>
      </td>
      <td>
        This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_act_visit() interface.<BR><BR>
        This functor fits a N-degree polynomial through the given x-y coordinates by the way of Least-Squares and Gaussian-Elimination<BR>
        The result gives you the vector of coefficients.<BR><BR>
        There is also a method <I>get_y_fits()</I> which returns the vector of y fits for each given x<BR>
        There is also a method <I>get_slope()</I> which returns the first (0-degree) coefficient.<BR>
        There is also a method <I>get_residual()</I> which returns the sum of weighted squared residuals.
        <I>
        <PRE>
    using weight_func = std::function&lt;T (const I &amp;idx, size_t val_index)&gt;;

    explicit
    PolyFitVisitor(std::size_t degree,
                   weight_func w_func = [](const I &, size_t) -> T { return (T(1)); });
		</PRE>
        </I>
        <B>degree</B>: The polynomial degree<BR>
        <B>w_func</B>: A functor that provides weights to be applied to sigma values. w_func is passed two parameters: (1) The value of the index column corresponding to the given y value, (2) The corresponding index into the y vector. The default is no weights.
      </td>
      <td width="12%">
        <B>T</B>: Column data type.<BR>
        <B>I</B>: Index type.<BR>
        <B>A</B>: Memory alignment boundary for vectors. Default is system default alignment<BR>
      </td>
    </tr>

    <tr bgcolor="lightgrey">
      <td bgcolor="maroon"> <font color="white">
        <PRE><B>#include &lt;DataFrame/DataFrameStatsVisitors.h&gt;

template&lt;typename T, typename I = unsigned long,
         std::size_t A = 0&gt;
struct LogFitVisitor;

// -------------------------------------

template&lt;typename T, typename I = unsigned long,
         std::size_t A = 0&gt;
using lfit_v = LogFitVisitor&lt;T, I, A&gt;;
        </B></PRE></font>
      </td>
      <td>
        This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_act_visit() interface.<BR><BR>
        This functor fits a <I>y = b<sub>0</sub> + b<sub>1</sub> * log(x)</I> through the given x-y coordinates by the way of calling PolyFit above on log(x).<BR>
        The result gives you the vector of two coefficients.<BR><BR>
        There is also a method <I>get_y_fits()</I> which returns the vector of y fits for each given x<BR>
        There is also a method <I>get_slope()</I> which returns the first (0-degree) coefficient.<BR>
        There is also a method <I>get_residual()</I> which returns the sum of weighted squared residuals.
        <I>
        <PRE>
    using weight_func = std::function&lt;T (const I &amp;idx, size_t val_index)&gt;;

    explicit
    LogFitVisitor(weight_func w_func = [](const I &, size_t) -> T { return (T(1)); });
		</PRE>
        </I>
        <B>w_func</B>: A functor that provides weights to be applied to sigma values. w_func is passed two parameters: (1) The value of the index column corresponding to the given y value, (2) The corresponding index into the y vector. The default is no weights.
      </td>
      <td width="12%">
        <B>T</B>: Column data type.<BR>
        <B>I</B>: Index type.<BR>
        <B>A</B>: Memory alignment boundary for vectors. Default is system default alignment<BR>
      </td>
    </tr>

    <tr bgcolor="lightgrey">
      <td bgcolor="maroon"> <font color="white">
        <PRE><B>#include &lt;DataFrame/DataFrameStatsVisitors.h&gt;

template&lt;typename T, typename I = unsigned long,
         std::size_t A = 0&gt;
struct ExponentialFitVisitor;

// -------------------------------------

template&lt;typename T, typename I = unsigned long,
         std::size_t A = 0&gt;
using efit_v = ExponentialFitVisitor&lt;T, I, A&gt;;
        </B></PRE></font>
      </td>
      <td>
        This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_act_visit() interface.<BR><BR>
        The result gives you the vector of y fits for each given x.<BR><BR>

        There is also a method <I>get_slope()</I> which returns the slope -- coefficient of the exponetial function.<BR>
        There is also a method <I>get_residual()</I> which returns the sum of squared residuals.<BR>
        There is also a method <I>get_intercept()</I> which returns the intercept.<BR>
        <I>
        <PRE>
    ExponentialFitVisitor();
		</PRE>
        </I>
      </td>
      <td width="12%">
        <B>T</B>: Column data type.<BR>
        <B>I</B>: Index type.<BR>
        <B>A</B>: Memory alignment boundary for vectors. Default is system default alignment<BR>
      </td>
    </tr>

    <tr bgcolor="lightgrey">
      <td bgcolor="maroon"> <font color="white">
        <PRE><B>#include &lt;DataFrame/DataFrameStatsVisitors.h&gt;

template&lt;typename T, typename I = unsigned long,
         std::size_t A = 0&gt;
struct LinearFitVisitor;

// -------------------------------------

template&lt;typename T, typename I = unsigned long,
         std::size_t A = 0&gt;
using linfit_v = LinearFitVisitor&lt;T, I, A&gt;;
        </B></PRE></font>
      </td>
      <td>
        This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_act_visit() interface.<BR><BR>
        The result gives you the vector of y fits for each given x.<BR><BR>

        There is also a method <I>get_slope()</I> which returns the slope -- coefficient of the exponetial function.<BR>
        There is also a method <I>get_residual()</I> which returns the sum of squared residuals.<BR>
        There is also a method <I>get_intercept()</I> which returns the intercept.<BR>
        <I>
        <PRE>
    LinearFitVisitor();
		</PRE>
        </I>
      </td>
      <td width="12%">
        <B>T</B>: Column data type.<BR>
        <B>I</B>: Index type.<BR>
        <B>A</B>: Memory alignment boundary for vectors. Default is system default alignment<BR>
      </td>
    </tr>

  </table>

<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">test_PolyFitVisitor</span>()  {

    std<span style="color: #333333">::</span>cout <span style="color: #333333">&lt;&lt;</span> <span style="background-color: #fff0f0">&quot;</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">Testing PolyFitVisitor{  } ...&quot;</span> <span style="color: #333333">&lt;&lt;</span> std<span style="color: #333333">::</span>endl;

    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">unsigned</span> <span style="color: #333399; font-weight: bold">long</span><span style="color: #333333">&gt;</span>  idx <span style="color: #333333">=</span>
        { <span style="color: #0000DD; font-weight: bold">123450</span>, <span style="color: #0000DD; font-weight: bold">123451</span>, <span style="color: #0000DD; font-weight: bold">123452</span>, <span style="color: #0000DD; font-weight: bold">123453</span>, <span style="color: #0000DD; font-weight: bold">123454</span>, <span style="color: #0000DD; font-weight: bold">123455</span>, <span style="color: #0000DD; font-weight: bold">123456</span>, <span style="color: #0000DD; font-weight: bold">123457</span>, <span style="color: #0000DD; font-weight: bold">123458</span>, <span style="color: #0000DD; font-weight: bold">123459</span>, <span style="color: #0000DD; font-weight: bold">123460</span>, <span style="color: #0000DD; font-weight: bold">123461</span>, <span style="color: #0000DD; font-weight: bold">123462</span>, <span style="color: #0000DD; font-weight: bold">123466</span>,
          <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>, <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>,
          <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>,
        };
    MyDataFrame                 df;

    df.load_index(std<span style="color: #333333">::</span>move(idx));
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">2</span>, <span style="color: #0000DD; font-weight: bold">3</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">5</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;Y1&quot;</span>, { <span style="color: #0000DD; font-weight: bold">6</span>, <span style="color: #0000DD; font-weight: bold">7</span>, <span style="color: #0000DD; font-weight: bold">8</span>, <span style="color: #0000DD; font-weight: bold">9</span>, <span style="color: #0000DD; font-weight: bold">3</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X2&quot;</span>, { <span style="color: #6600EE; font-weight: bold">0.0</span>, <span style="color: #6600EE; font-weight: bold">1.0</span>, <span style="color: #6600EE; font-weight: bold">2.0</span>, <span style="color: #6600EE; font-weight: bold">3.0</span>,  <span style="color: #6600EE; font-weight: bold">4.0</span>,  <span style="color: #6600EE; font-weight: bold">5.0</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;Y2&quot;</span>, { <span style="color: #6600EE; font-weight: bold">0.0</span>, <span style="color: #6600EE; font-weight: bold">0.8</span>, <span style="color: #6600EE; font-weight: bold">0.9</span>, <span style="color: #6600EE; font-weight: bold">0.1</span>, <span style="color: #333333">-</span><span style="color: #6600EE; font-weight: bold">0.8</span>, <span style="color: #333333">-</span><span style="color: #6600EE; font-weight: bold">1.0</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);

    PolyFitVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>  poly_v1 (<span style="color: #0000DD; font-weight: bold">2</span>);
    PolyFitVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>  poly_v12 (
        <span style="color: #0000DD; font-weight: bold">2</span>,
        [](<span style="color: #008800; font-weight: bold">const</span> <span style="color: #333399; font-weight: bold">unsigned</span> <span style="color: #333399; font-weight: bold">int</span> <span style="color: #333333">&amp;</span>, std<span style="color: #333333">::</span><span style="color: #333399; font-weight: bold">size_t</span> i) <span style="color: #333333">-&gt;</span> <span style="color: #333399; font-weight: bold">double</span> {
            <span style="color: #008800; font-weight: bold">const</span> std<span style="color: #333333">::</span>array<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #0000DD; font-weight: bold">5</span><span style="color: #333333">&gt;</span> weights <span style="color: #333333">=</span> { <span style="color: #6600EE; font-weight: bold">0.1</span>, <span style="color: #6600EE; font-weight: bold">0.8</span>, <span style="color: #6600EE; font-weight: bold">0.3</span>, <span style="color: #6600EE; font-weight: bold">0.5</span>, <span style="color: #6600EE; font-weight: bold">0.2</span> };

            <span style="color: #008800; font-weight: bold">return</span> (weights[i]);
        });
    <span style="color: #008800; font-weight: bold">auto</span>                    result1 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, <span style="background-color: #fff0f0">&quot;Y1&quot;</span>, poly_v1).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>                    result12 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, <span style="background-color: #fff0f0">&quot;Y1&quot;</span>, poly_v12).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>                    actual1 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">0.8</span>, <span style="color: #6600EE; font-weight: bold">5.6</span>, <span style="color: #333333">-</span><span style="color: #0000DD; font-weight: bold">1</span> };
    <span style="color: #008800; font-weight: bold">auto</span>                    actual1_y <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">5.4</span>, <span style="color: #0000DD; font-weight: bold">8</span>, <span style="color: #6600EE; font-weight: bold">8.6</span>, <span style="color: #6600EE; font-weight: bold">7.2</span>, <span style="color: #6600EE; font-weight: bold">3.8</span> };
    <span style="color: #008800; font-weight: bold">auto</span>                    actual12 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #333333">-</span><span style="color: #6600EE; font-weight: bold">1.97994</span>, <span style="color: #6600EE; font-weight: bold">6.99713</span>, <span style="color: #333333">-</span><span style="color: #6600EE; font-weight: bold">1.14327</span> };

    assert(std<span style="color: #333333">::</span>fabs(poly_v1.get_residual() <span style="color: #333333">-</span> <span style="color: #6600EE; font-weight: bold">5.6</span>) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result1.size(); <span style="color: #333333">++</span>i)
       assert(fabs(result1[i] <span style="color: #333333">-</span> actual1[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> poly_v1.get_y_fits().size(); <span style="color: #333333">++</span>i)
       assert(fabs(poly_v1.get_y_fits()[i] <span style="color: #333333">-</span> actual1_y[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.01</span>);

    assert(std<span style="color: #333333">::</span>fabs(poly_v12.get_residual() <span style="color: #333333">-</span> <span style="color: #6600EE; font-weight: bold">0.70981</span>) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result12.size(); <span style="color: #333333">++</span>i)
       assert(fabs(result12[i] <span style="color: #333333">-</span> actual12[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);

    PolyFitVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>  poly_v2 (<span style="color: #0000DD; font-weight: bold">3</span>);
    <span style="color: #008800; font-weight: bold">auto</span>                    result2 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X2&quot;</span>, <span style="background-color: #fff0f0">&quot;Y2&quot;</span>, poly_v2).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>                    actual2 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #333333">-</span><span style="color: #6600EE; font-weight: bold">0.0396825</span>, <span style="color: #6600EE; font-weight: bold">1.69312</span>, <span style="color: #333333">-</span><span style="color: #6600EE; font-weight: bold">0.813492</span>, <span style="color: #6600EE; font-weight: bold">0.087037</span> };

    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result2.size(); <span style="color: #333333">++</span>i)
       assert(fabs(result2[i] <span style="color: #333333">-</span> actual2[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
}

<span style="color: #888888">// -----------------------------------------------------------------------------</span>

<span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">test_LogFitVisitor</span>()  {

    std<span style="color: #333333">::</span>cout <span style="color: #333333">&lt;&lt;</span> <span style="background-color: #fff0f0">&quot;</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">Testing LogFitVisitor{  } ...&quot;</span> <span style="color: #333333">&lt;&lt;</span> std<span style="color: #333333">::</span>endl;

    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">unsigned</span> <span style="color: #333399; font-weight: bold">long</span><span style="color: #333333">&gt;</span>  idx <span style="color: #333333">=</span>
        { <span style="color: #0000DD; font-weight: bold">123450</span>, <span style="color: #0000DD; font-weight: bold">123451</span>, <span style="color: #0000DD; font-weight: bold">123452</span>, <span style="color: #0000DD; font-weight: bold">123453</span>, <span style="color: #0000DD; font-weight: bold">123454</span>, <span style="color: #0000DD; font-weight: bold">123455</span>, <span style="color: #0000DD; font-weight: bold">123456</span>, <span style="color: #0000DD; font-weight: bold">123457</span>, <span style="color: #0000DD; font-weight: bold">123458</span>, <span style="color: #0000DD; font-weight: bold">123459</span>, <span style="color: #0000DD; font-weight: bold">123460</span>, <span style="color: #0000DD; font-weight: bold">123461</span>, <span style="color: #0000DD; font-weight: bold">123462</span>, <span style="color: #0000DD; font-weight: bold">123466</span>,
          <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>, <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>,
          <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>,
        };
    MyDataFrame                 df;

    df.load_index(std<span style="color: #333333">::</span>move(idx));
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">2</span>, <span style="color: #0000DD; font-weight: bold">3</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">5</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;Y1&quot;</span>, { <span style="color: #0000DD; font-weight: bold">6</span>, <span style="color: #0000DD; font-weight: bold">7</span>, <span style="color: #0000DD; font-weight: bold">8</span>, <span style="color: #0000DD; font-weight: bold">9</span>, <span style="color: #0000DD; font-weight: bold">3</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X2&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">2</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">6</span>, <span style="color: #0000DD; font-weight: bold">8</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;Y2&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">3</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">5</span>, <span style="color: #0000DD; font-weight: bold">6</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);

    LogFitVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>   log_v1;
    <span style="color: #008800; font-weight: bold">auto</span>                    result1 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, <span style="background-color: #fff0f0">&quot;Y1&quot;</span>, log_v1).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>                    actual1 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">6.98618</span>, <span style="color: #333333">-</span><span style="color: #6600EE; font-weight: bold">0.403317</span> };
    <span style="color: #008800; font-weight: bold">auto</span>                    actual1_y <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">6.98618</span>, <span style="color: #6600EE; font-weight: bold">6.70662</span>, <span style="color: #6600EE; font-weight: bold">6.54309</span>, <span style="color: #6600EE; font-weight: bold">6.42706</span>, <span style="color: #6600EE; font-weight: bold">6.33706</span> };

    assert(std<span style="color: #333333">::</span>fabs(log_v1.get_residual() <span style="color: #333333">-</span> <span style="color: #6600EE; font-weight: bold">20.9372</span>) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.0001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result1.size(); <span style="color: #333333">++</span>i)
       assert(fabs(result1[i] <span style="color: #333333">-</span> actual1[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> log_v1.get_y_fits().size(); <span style="color: #333333">++</span>i)
       assert(fabs(log_v1.get_y_fits()[i] <span style="color: #333333">-</span> actual1_y[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.01</span>);

    LogFitVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>   log_v2;
    <span style="color: #008800; font-weight: bold">auto</span>                    result2 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X2&quot;</span>, <span style="background-color: #fff0f0">&quot;Y2&quot;</span>, log_v2).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>                    actual2 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">1.11199</span>, <span style="color: #6600EE; font-weight: bold">2.25859</span> };

    assert(std<span style="color: #333333">::</span>fabs(log_v2.get_residual() <span style="color: #333333">-</span> <span style="color: #6600EE; font-weight: bold">0.237476</span>) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result2.size(); <span style="color: #333333">++</span>i)
       assert(fabs(result2[i] <span style="color: #333333">-</span> actual2[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
}

<span style="color: #888888">// -----------------------------------------------------------------------------</span>

<span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">test_ExponentialFitVisitor</span>()  {

    std<span style="color: #333333">::</span>cout <span style="color: #333333">&lt;&lt;</span> <span style="background-color: #fff0f0">&quot;</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">Testing ExponentialFitVisitor{  } ...&quot;</span> <span style="color: #333333">&lt;&lt;</span> std<span style="color: #333333">::</span>endl;

    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">unsigned</span> <span style="color: #333399; font-weight: bold">long</span><span style="color: #333333">&gt;</span>  idx <span style="color: #333333">=</span>
        { <span style="color: #0000DD; font-weight: bold">123450</span>, <span style="color: #0000DD; font-weight: bold">123451</span>, <span style="color: #0000DD; font-weight: bold">123452</span>, <span style="color: #0000DD; font-weight: bold">123453</span>, <span style="color: #0000DD; font-weight: bold">123454</span>, <span style="color: #0000DD; font-weight: bold">123455</span>, <span style="color: #0000DD; font-weight: bold">123456</span>, <span style="color: #0000DD; font-weight: bold">123457</span>, <span style="color: #0000DD; font-weight: bold">123458</span>, <span style="color: #0000DD; font-weight: bold">123459</span>, <span style="color: #0000DD; font-weight: bold">123460</span>, <span style="color: #0000DD; font-weight: bold">123461</span>, <span style="color: #0000DD; font-weight: bold">123462</span>, <span style="color: #0000DD; font-weight: bold">123466</span>,
          <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>, <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>,
          <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>,
        };
    MyDataFrame                 df;

    df.load_index(std<span style="color: #333333">::</span>move(idx));
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">2</span>, <span style="color: #0000DD; font-weight: bold">3</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">5</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;Y1&quot;</span>, { <span style="color: #0000DD; font-weight: bold">6</span>, <span style="color: #0000DD; font-weight: bold">7</span>, <span style="color: #0000DD; font-weight: bold">8</span>, <span style="color: #0000DD; font-weight: bold">9</span>, <span style="color: #0000DD; font-weight: bold">3</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X2&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">2</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">6</span>, <span style="color: #0000DD; font-weight: bold">8</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;Y2&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">3</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">5</span>, <span style="color: #0000DD; font-weight: bold">6</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);

    ExponentialFitVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>   exp_v1;
    <span style="color: #008800; font-weight: bold">auto</span>                            result1 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, <span style="background-color: #fff0f0">&quot;Y1&quot;</span>, exp_v1).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>                            actual1 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">7.7647</span>, <span style="color: #6600EE; font-weight: bold">6.9316</span>, <span style="color: #6600EE; font-weight: bold">6.1879</span>, <span style="color: #6600EE; font-weight: bold">5.5239</span>, <span style="color: #6600EE; font-weight: bold">4.93126</span> };

    assert(std<span style="color: #333333">::</span>fabs(exp_v1.get_residual() <span style="color: #333333">-</span> <span style="color: #6600EE; font-weight: bold">22.2154</span>) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.0001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result1.size(); <span style="color: #333333">++</span>i)
        assert(fabs(result1[i] <span style="color: #333333">-</span> actual1[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.0001</span>);

    efit_v<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>  exp_v2;
    <span style="color: #008800; font-weight: bold">auto</span>            result2 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X2&quot;</span>, <span style="background-color: #fff0f0">&quot;Y2&quot;</span>, exp_v2).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>            actual2 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">1.63751</span>, <span style="color: #6600EE; font-weight: bold">2.02776</span>, <span style="color: #6600EE; font-weight: bold">3.10952</span>, <span style="color: #6600EE; font-weight: bold">4.76833</span>, <span style="color: #6600EE; font-weight: bold">7.31206</span> };

    assert(std<span style="color: #333333">::</span>fabs(exp_v2.get_residual() <span style="color: #333333">-</span> <span style="color: #6600EE; font-weight: bold">3.919765</span>) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result2.size(); <span style="color: #333333">++</span>i)
        assert(fabs(result2[i] <span style="color: #333333">-</span> actual2[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.0001</span>);
}

<span style="color: #888888">// -----------------------------------------------------------------------------</span>

<span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">test_LinearFitVisitor</span>()  {

    std<span style="color: #333333">::</span>cout <span style="color: #333333">&lt;&lt;</span> <span style="background-color: #fff0f0">&quot;</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">Testing LinearFitVisitor{  } ...&quot;</span> <span style="color: #333333">&lt;&lt;</span> std<span style="color: #333333">::</span>endl;

    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">unsigned</span> <span style="color: #333399; font-weight: bold">long</span><span style="color: #333333">&gt;</span>  idx <span style="color: #333333">=</span>
        { <span style="color: #0000DD; font-weight: bold">123450</span>, <span style="color: #0000DD; font-weight: bold">123451</span>, <span style="color: #0000DD; font-weight: bold">123452</span>, <span style="color: #0000DD; font-weight: bold">123453</span>, <span style="color: #0000DD; font-weight: bold">123454</span>, <span style="color: #0000DD; font-weight: bold">123455</span>, <span style="color: #0000DD; font-weight: bold">123456</span>, <span style="color: #0000DD; font-weight: bold">123457</span>, <span style="color: #0000DD; font-weight: bold">123458</span>, <span style="color: #0000DD; font-weight: bold">123459</span>, <span style="color: #0000DD; font-weight: bold">123460</span>, <span style="color: #0000DD; font-weight: bold">123461</span>, <span style="color: #0000DD; font-weight: bold">123462</span>, <span style="color: #0000DD; font-weight: bold">123466</span>,
          <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>, <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>,
          <span style="color: #0000DD; font-weight: bold">123467</span>, <span style="color: #0000DD; font-weight: bold">123468</span>, <span style="color: #0000DD; font-weight: bold">123469</span>, <span style="color: #0000DD; font-weight: bold">123470</span>, <span style="color: #0000DD; font-weight: bold">123471</span>, <span style="color: #0000DD; font-weight: bold">123472</span>, <span style="color: #0000DD; font-weight: bold">123473</span>,
        };
    MyDataFrame                 df;

    df.load_index(std<span style="color: #333333">::</span>move(idx));
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">2</span>, <span style="color: #0000DD; font-weight: bold">3</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">5</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;Y1&quot;</span>, { <span style="color: #0000DD; font-weight: bold">6</span>, <span style="color: #0000DD; font-weight: bold">7</span>, <span style="color: #0000DD; font-weight: bold">8</span>, <span style="color: #0000DD; font-weight: bold">9</span>, <span style="color: #0000DD; font-weight: bold">3</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X2&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">2</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">6</span>, <span style="color: #0000DD; font-weight: bold">8</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);
    df.load_column<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;Y2&quot;</span>, { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">3</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">5</span>, <span style="color: #0000DD; font-weight: bold">6</span> }, nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);

    LinearFitVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>    lin_v1;
    <span style="color: #008800; font-weight: bold">auto</span>                        result1 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X1&quot;</span>, <span style="background-color: #fff0f0">&quot;Y1&quot;</span>, lin_v1).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>                        actual1 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">7.4</span>, <span style="color: #0000DD; font-weight: bold">7</span>, <span style="color: #6600EE; font-weight: bold">6.6</span>, <span style="color: #6600EE; font-weight: bold">6.2</span>, <span style="color: #6600EE; font-weight: bold">5.8</span> };

    assert(std<span style="color: #333333">::</span>fabs(lin_v1.get_residual() <span style="color: #333333">-</span> <span style="color: #6600EE; font-weight: bold">19.6</span>) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.01</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result1.size(); <span style="color: #333333">++</span>i)
        assert(fabs(result1[i] <span style="color: #333333">-</span> actual1[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.0001</span>);

    linfit_v<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>    lin_v2;
    <span style="color: #008800; font-weight: bold">auto</span>                result2 <span style="color: #333333">=</span> df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;X2&quot;</span>, <span style="background-color: #fff0f0">&quot;Y2&quot;</span>, lin_v2).get_result();
    <span style="color: #008800; font-weight: bold">auto</span>                actual2 <span style="color: #333333">=</span> std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span> { <span style="color: #6600EE; font-weight: bold">1.73171</span>, <span style="color: #6600EE; font-weight: bold">2.37805</span>, <span style="color: #6600EE; font-weight: bold">3.67073</span>, <span style="color: #6600EE; font-weight: bold">4.96341</span>, <span style="color: #6600EE; font-weight: bold">6.2561</span> };

    assert(std<span style="color: #333333">::</span>fabs(lin_v2.get_residual() <span style="color: #333333">-</span> <span style="color: #6600EE; font-weight: bold">1.097561</span>) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.00001</span>);
    <span style="color: #008800; font-weight: bold">for</span> (<span style="color: #333399; font-weight: bold">size_t</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; i <span style="color: #333333">&lt;</span> result2.size(); <span style="color: #333333">++</span>i)
        assert(fabs(result2[i] <span style="color: #333333">-</span> actual2[i]) <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">0.0001</span>);
}
</pre></div>

  <img src="https://github.com/hosseinmoein/DataFrame/blob/master/docs/LionLookingUp.jpg?raw=true" alt="C++ DataFrame"
       width="200" height="150" style="float:right"/>

</body>
</html>

<!--
Local Variables:
mode:HTML
tab-width:4
c-basic-offset:4
End:
-->
